function FBConnectedHandler(access_token, uid) {
    $('#fb-hello').html('Recupero informazioni profilo...');

    $.post("FacebookController?userauth",
           {accesstoken: access_token,
            fbuid: uid},
           function(data) {
               if(data.status === 0) {
                    data.message = $.parseJSON(data.message);
                    $('#fb-hello').html("Benvenut" + (data.message.gender==="male" ? "o" : "a") + "<br><b>" + data.message.name + "</b>!");
                    $('.fb-img').attr("src","https://graph.facebook.com/" + uid + "/picture?type=small");
                }
                else {
                    $('#modal-window .modal-title').html("Errore Facebook!");
                    $('#modal-window #modal-message').html(data.message);
                    $('#modal-window').modal('show');
                }
           },
           'json');
}

function FBNotAuthorizedHandler() {
    console.log("FB Not Authorized Handler");
    $('#fb-hello').html("Non hai autorizzato questa applicazione.<br>Rieffettua il login!");
    $('.fb-img').attr("src","");
}

function FBNotLoggedUserHandler() {
    console.log("FB Not Logged User Handler");
    $('#fb-hello').html("");
    $('.fb-img').attr("src","");
}

function FBNoAuthConnectedHandler() {
    console.log("FB No Auth Connected Handler");
    $('#fb-hello').html("");
    $('.fb-img').attr("src","");
}

function FBUserLogoutHandler(response) {
    console.log("FB User Logout Handler");
    $('#fb-hello').html("");
    $('.fb-img').attr("src","");
}